﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace _05.FindCycles
{
    class FindCycles
    {
        static void Main(string[] args)
        {
            List<int>[] nodes = new List<int>[7];
            nodes[0] = new int[] { 3, 6 }.ToList();
            nodes[1] = new int[] { 2, 3, 4, 5, 6 }.ToList();
            nodes[2] = new int[] { 1, 4, 5 }.ToList();
            nodes[3] = new int[] { 0, 1, 5 }.ToList();
            nodes[4] = new int[] { 1, 2, 6 }.ToList();
            nodes[5] = new int[] { 1, 2, 3 }.ToList();
            nodes[6] = new int[] { 0, 1, 4 }.ToList();

            Graph graph = new Graph(nodes);

            Print(graph.FindCycles());
        }

        static void Print(List<List<int>> cycles)
        {
            for (int i = 0; i < cycles.Count; i++)
            {
                Console.Write("{0, 3}. ", i + 1);
                for (int j = 0; j < cycles[i].Count; j++)
                {
                    if (j < cycles[i].Count - 1)
                    {
                        Console.Write("{0}, ", cycles[i][j]);
                    }
                    else
                    {
                        Console.WriteLine("{0}", cycles[i][j]);
                    }
                }
            }
        }
    }
}
